
mylist = ["itheima","python","itcast"]


# 1.找到特定元素的索引值
# mylist.index(要找的元素)
"""
index = mylist.index("itheima")
print(f"{index}")


index = mylist.index("hello")
print(f"{index}")




"""

# 2.修改特定的索引值
# mylist[0] = "hello"
"""
mylist[0]="hello"
print(f"列表被修改后元素的值，结果是：{mylist}")
"""



# 3.修改特定下标索引值
# mylist.insert(1,"stop")
# 在下标为 1 的地方插入“stop”
"""
mylist.insert(1,"stop")
print(f"列表插入元素后，结果是：{mylist}")

"""


# 4.在列表尾部追加 单个 新元素
# append
"""
mylist.append("world")
print(f"列表在追加元素后：{mylist}")

"""

# 5.在列表尾部追加 一批 元素
# 
# mylist2 = [1,2,3]
# mylist.extend(mylist2)


# 6.1 删除方式1
"""
mylist = ["itcast","itheima","python"]
del mylist[2]
print(f"列表删除元素后结果是：{mylist}")
"""

# 6.2 删除方式2
"""
mylist = ["itcast","itheima","python"]
element = mylist.pop(0)
print(f"列表删除元素后结果是：{mylist}",end = " ")
print(f"pop删除的元素是{element}")


"""

# 7.删除某元素在列表中的第一个匹配项

"""
mylist = ["hello","itheima","world","itheima","python"]
mylist.remove("itheima")
print(f"列表删除元素后的结果是：{mylist}")
"""


# 8.清空列表
"""
mylist.clear()
print(f"列表被清空了，结果是{mylist}")

"""

# 9.统计列表内 某元素的数量
""""
mylist = ["itcast","itheima","itcast","itheima","python"]
count = mylist.count("itheima")
print(f"itheima的数量为{count}")


"""

# 10. 统计列表中全部的元素数量
mylist = [1,2,3,4,5,6,7,8,9]
count = len(mylist)
print(f"列表的长度为：{count}")

